<?php

class AdminModule extends CWebModule
{
	public function init() {
		
		$this->publishAssets();
		// this method is called when the module is being created
		// you may place code here to customize the module or the application

		// import the module-level models and components
		$this->setImport(array(
			//'admin.models.*',
			'admin.components.*',
		));
	}

	public function beforeControllerAction($controller, $action) {
		if(parent::beforeControllerAction($controller, $action))
		{
			// this method is called before any module controller action is performed
			// you may place customized code here
			return true;
		}
		else
			return false;
	}
	
	protected static function publishAssets()
	{
		$assets=dirname(__FILE__).'/assets';
		$baseUrl=Yii::app()->assetManager->publish($assets);
		if(is_dir($assets)) {
//			Yii::app()->clientScript->registerScriptFile($baseUrl.'/some.js',CClientScript::POS_HEAD);
			Yii::app()->clientScript->registerCssFile($baseUrl.'/css/admin.css');
		} else {
			throw new Exception('Admin module - Error: Couldn\'t find assets to publish.');
		}
	}	
    
	public static function t($str='',$params=array(), $dic='admin') {
		return Yii::t('AdminModule.'.$dic, $str, $params);
	}      
    
	
}
